//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.web.controller.finance;

import com.aidong.dao.base.ConditionMap;
import com.aidong.dao.base.OrderSet;
import com.aidong.dao.base.Pagination;
import com.aidong.dao.wills.PayBaosteelDao;
import com.aidong.model.wills.PayBaosteel;
import com.aidong.util.ExportXls;
import com.aidong.web.controller.BaseController;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping({"payBaosteel"})
public class PayBaosteelController extends BaseController {
    @Resource
    PayBaosteelDao payBaosteelDao;

    public PayBaosteelController() {
    }

    @RequestMapping({"list"})
    public ModelAndView list() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return (new ModelAndView("finance/paybaosteel/list")).addObject("payaliStatus", this.getTypeList("payaliStatus")).addObject("dt1", sdf.format(new Date(System.currentTimeMillis() - 86400000L))).addObject("dt2", sdf.format(new Date()));
    }

    @RequestMapping({"_list"})
    public ModelAndView _list(@RequestParam(value = "shopCode",required = false) String shopCode, @RequestParam(value = "status",required = false) Integer status, @RequestParam(value = "dateFrom",required = false) String dateFrom, @RequestParam(value = "dateTo",required = false) String dateTo, @RequestParam(value = "pageNo",required = false) String pageNo, @RequestParam(value = "totalCount",required = false) String totalCount) {
        Pagination pg = new Pagination(1, 20);
        pg.setPage(this.parseInt(pageNo), this.parseInt(totalCount));
        ConditionMap cd = new ConditionMap();
        this.addConditionShopCode(cd, "shopCode", shopCode);
        cd.eq("status", status);
        if(!this.chkNull(dateFrom)) {
            cd.ge("createTime", this.getDateFrom(dateFrom));
        }

        if(!this.chkNull(dateTo)) {
            cd.le("createTime", this.getDateTo(dateTo));
        }

        this.payBaosteelDao.queryPageList(pg, cd, (new OrderSet()).desc("createTime"));
        ModelAndView mv = new ModelAndView("finance/paybaosteel/_list");
        mv.addObject("list", pg.getResultList());
        mv.addObject("pg", pg);
        return mv;
    }

    @RequestMapping({"expt"})
    public ModelAndView expt(@RequestParam(value = "shopCode",required = false) String shopCode, @RequestParam(value = "status",required = false) Integer status, @RequestParam(value = "dateFrom",required = false) String dateFrom, @RequestParam(value = "dateTo",required = false) String dateTo, HttpServletResponse response) {
        try {
            Pagination e = new Pagination(1, '\uea60');
            e.setPage(Integer.valueOf(1), Integer.valueOf(1));
            ConditionMap cd = new ConditionMap();
            this.addConditionShopCode(cd, "shopCode", shopCode);
            cd.eq("status", status);
            if(!this.chkNull(dateFrom)) {
                cd.ge("createTime", this.getDateFrom(dateFrom));
            }

            if(!this.chkNull(dateTo)) {
                cd.le("createTime", this.getDateTo(dateTo));
            }

            this.payBaosteelDao.queryPageList(e, cd, (new OrderSet()).desc("createTime"));
            ExportXls xls = new ExportXls(response, "宝钢支付流水", "宝钢支付流水");
            xls.addHead(new String[]{"门店编号", "门店名称", "时间", "付款手机号", "金额", "状态", "付款时间", "支付单号", "支付序号", "支付流水号", "操作员"});
            xls.setWidth(new int[]{10, 10, 20, 20, 10, 10, 20, 22, 10, 10, 15});
            new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            if(e.getResultList() != null) {
                Iterator i$ = e.getResultList().iterator();

                while(i$.hasNext()) {
                    PayBaosteel pay = (PayBaosteel)i$.next();
                    xls.addRow(new Object[]{pay.getShopCode(), this.cache.getValue("shopName", pay.getShopCode()), sdf2.format(pay.getCreateTime()), pay.getPayUser(), pay.getAmount(), this.cache.getValue("payaliStatus", String.valueOf(pay.getStatus())), pay.getPayTime() == null?null:sdf2.format(pay.getPayTime()), pay.getTradeNo(), pay.getSerialNo(), pay.getPayListId(), this.nvl(pay.getCreateUser()) + " - " + this.nvl(this.cache.getValue("userName", pay.getCreateUser()))});
                }
            }

            xls.close();
            this.addUserLog("导出宝钢支付流水", e.getResultList().size() + "条记录");
        } catch (Exception var13) {
            this.log.error("import", var13);
        }

        return null;
    }
}
